import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

// 导入flexible.js设置rem的基准值
import 'lib-flexible/flexible'

import { Tabbar,Divider,Form,Field,Overlay,ActionSheet, Tab,NoticeBar,Rate ,ShareSheet,Collapse, CollapseItem, Tabs,List,Button,PullRefresh,Switch,Badge,Icon,Card,TabbarItem,Search, NavBar, Empty,Cell, CellGroup,Sticky,Toast , Swipe, SwipeItem, DropdownMenu, DropdownItem,Grid, GridItem} from 'vant';
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueRouter from 'vue-router'


Vue.use(Tabbar); 
Vue.use(ActionSheet); 
Vue.use(Overlay); 
Vue.use(Divider); 
Vue.use(Rate ); 
Vue.use(NoticeBar); 
Vue.use(Switch); 
Vue.use(Button); 
Vue.use(PullRefresh); 
Vue.use(ShareSheet); 
Vue.use(Badge); 
Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(TabbarItem);
Vue.use(Search);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Card);
Vue.use(Sticky);
Vue.use(Toast);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Grid);
Vue.use(GridItem);
Vue.use(Empty);
Vue.use(NavBar);
Vue.use(Icon);
Vue.use(List);
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(Form);
Vue.use(Field);


axios.defaults.baseURL = 'https://apis.netstart.cn/yunyuedu/';

axios.interceptors.request.use(config => {

  Toast.loading({
    message:"加载中...",
    forbidClick:true,
    loadingType:'spinner',
    duration:0,
  })
  return config;
},err =>{
  console.log(err);
  Toast.clear();
  return Promise.reject(err)
})

axios.interceptors.response.use(res =>{
  Toast.clear();
  return res
},err =>{
  console.log(err);
  Toast.clear();
  return Promise.reject(err)
})

Vue.use(VueAxios, axios)
Vue.config.productionTip = false

// router.beforeEach((to,from,next) => {
//   console.log(to);
//   if(to.name === "LocalBookShelf"){

//   }
//   next()
// })

let originPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location,resolve,reject) {
  originPush.call(this,location,() =>{},(err) =>{

  });
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
